package vue.stage;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import ctr.commun.CommunGest;
import ctr.stage.GestSuppStage;

public class JPanSuppStage extends JPanel{

	private static final long serialVersionUID = -8258905260255616984L;
	private JComboBox jComboBox;
	
	public JPanSuppStage(String titre) {
		// Recuperation et creation de la comboBox de liste des stages.
		CommunGest communGest = new CommunGest();
		jComboBox = new JComboBox(communGest.getListeStage().toArray());
		JButton jButtonSupp = new JButton("Supprimer");
		// On passe au listener l'instance de l'objet pour qu'il accede à la comboxBox. 
		jButtonSupp.addActionListener(new GestSuppStage(this));
		
		// Ajout des differents composants.
		this.setBorder(new TitledBorder(titre));
		this.setLayout(new FlowLayout());
		this.add(jComboBox);
		this.add(jButtonSupp);
	}
	
	public JComboBox getjComboBox() {
		return jComboBox;
	}
}
